<script type="text/javascript" src="<?php echo base_url('assets/js/messages.js'); ?>"></script>
<?php	$email = $_SESSION['email'];
		$msgtype = $this->uri->segment(3);
		$preview = true;
		if($msgtype == 'notes' || $msgtype== 'journal' || $msgtype == 'documents' ){
			$preview = false;
		}
	 $recipients = myuser_helper::getUserRecipients();
	 $usertype = strtolower(trim(Myuser_helper::get_user_type($_SESSION['email'])));//vip,free or reseller
?>

<div id = "main-contentz">
	<?php if($usertype == 'vip' || ($usertype == 'free' && $msgtype == 'notes')):?>
		<a href="<?php echo base_url('messages/add').'/'.$msgtype; ?>"><div id = "btn-messages">
			<p>Add Message</p>
		</div></a>
	<?php endif;?>
	<div id = "main-content-area">
		<input type="hidden" id="toX" name="toX" value="0" />
		<input type="hidden" id="toY" name="toY" value="0" />
		<div id = "main-content-wrap" class="scroll-pane">
			<?php if($usertype == 'vip' || ($usertype == 'free' && $msgtype == 'notes')){ ?>
			<div id = "messages-area">
				<table id = "tbl-messages-th" border = "0">
					<tr>
						<?php if ($preview) echo '<th scope="col" width = "100">Preview</th>';?>
						<th scope="col">Details</th>
						<th scope="col" width = "80">Action</th>
					</tr>
				</table>
				<table id = "tbl-messages" border = "0">
					<tr>
						<?php if ($preview) echo '<th scope="col" width = "100"></th>'; ?>
						<th scope="col"></th>
						<th scope="col" width = "80"></th>
					</tr>
					<?php foreach($message as $row):?>

						<tr class="mssg" id="mssg<?php echo $row->messageid; ?>">
							<?php 
								if ($preview){
									if($row->type=='videos'){
										echo '<td><img src="'.base_url().'assets/images/video-thumb.png" class="thumbpreview" /></td>';
									} else {
										$src = image_helper::resize_photo($row->thumb, '85', '60'); 
										echo '<td><img src="'.$src.'" class="thumbpreview" /></td>';
									}
								}
							?>
							<td>
							<?php $id=urlencode($this->encryption_lib->encode($row->messageid)); ?>
							<a class="msg-subject" href="<?php echo base_url().'messages/view/'.$this->uri->segment(3).'/'.$id; ?>">
							<span><?php echo ucwords($row->subject); ?></span></a><br />
							<span class="msg-add-details"><?php echo date('M d, Y',strtotime($row->date_added)).' | Sent to '.getTotype($row->totype); ?>
							<?php
								$noRecip = false;
								if($row->totype == 'specific'){
									echo '<div id="msg-recip-mainwrap">';
									echo '<div>';
									echo '<div class="sent-dropdown" onclick="javascript:recipDropdown('.$row->messageid.')">.</div>';
									$reciplist = Myuser_helper::getRecipients($row->messageid);
									if(!empty($reciplist)){
										echo '<div id="msg-recipient-wrap-'.$row->messageid.'" class="absolute-recip" onmouseout="javascript:toggleRecipWrap();">';
										echo '<ol class="recip-ol">';
										foreach(@$reciplist as $k=>$recip){
											//print_r($recip);
											echo '<li><span class="recip-ol-name">'.ucfirst(@$recip->fname).' '.ucfirst(@$recip->mname).' '.ucfirst(@$recip->lname).'</span><span class="recip-ol-email"> &lt;'.@$recip->email.'&gt;</span></li>';
										}
										echo '</ol>';
										echo '</div>';
									} else {
										echo '<div id="msg-recipient-wrap-'.$row->messageid.'" class="absolute-recip">';
										echo '<span>No recipient for this message.</span>';
										echo '</div>';
									}


							?>


									<br />

								</span>
							<?php } ?>
							</span>
							</span>

							</td>

							<td>
							 <?php

							    $pdf_url = site_url().'/messages/type/pdf/'.$row->pdf_id;
							 ?>
							<a class="get-pdf-file" href="<?php ?><?php echo $pdf_url?>" title="Download code details">.</a><a href="#" class="msg-delete-btn" title="Delete this message" onclick="javascript:DeleteMessage('<?php echo $row->messageid; ?>');">.</a></td>
						</tr>
					<?php endforeach; ?>
				</table>
			</div>
			<?php }else{ ?>
				<div class="error_msg" style="display: block;">You're not allowed to access this page.</div>
			<?php }//end if?>
			<form name="frm_msg_show" method="post"><input type="hidden" value="<?php echo base_url();?>" id="baseurl" name="baseurl"/></form>
		</div>
	</div>
</div>






